package com.wechat.wechat.utils;

import com.wechat.wechat.enums.CodeEnum;

/**
 * @author NN
 * @2020/2/26 14:04
 */
public class EnumUtil {
    /**
     * 根据code获取某个枚举下的枚举
     */
    public static <T extends CodeEnum> T getByCode(Integer code,Class<T> enumClass)
    {
        //遍历枚举类下的每一个枚举
        for(T each: enumClass.getEnumConstants()){
            if(code.equals(each.getCode()))
            {
                return each;
            }
        }
        return null;
    }
}
